package cn.wujiangbo.test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 多线程
 */
public class ThreadTest_1 {

    public static void main(String[] args) throws InterruptedException {
        Long start = System.currentTimeMillis();
        final Random random = new Random();
        final List<Integer> list = new ArrayList<>();

        for(int i=1; i<=10000; i++){
            Thread thread = new Thread(){
                @Override
                public void run() {
                    list.add(random.nextInt());
                }
            };
            thread.start();
            thread.join();
        }
        Long end = System.currentTimeMillis();
        System.out.println("运行时间：" + (end-start) + "毫秒");//1365
        System.out.println("List大小：" + list.size());
    }
}